package cn.ztuo.bitrade.dao;

import cn.ztuo.bitrade.dao.base.BaseDao;
import cn.ztuo.bitrade.entity.IeoOdfrecord;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.math.BigDecimal;
import java.util.List;

public interface IeoOdfrecordDao extends BaseDao<IeoOdfrecord> {


    List<IeoOdfrecord> findAllByTypeNotAndStatus(Integer type,String status);

    @Query(value ="select ieo_id from ieo_odfrecord where type IN (:types) and user_id=:id",nativeQuery = true)
    List<Long> selectTypes(@Param("id") Long id,@Param("types") List<Integer> types);

    @Query(value ="select sum(receive_amount) from ieo_odfrecord where type IN (:types) and user_id=:id",nativeQuery = true)
    BigDecimal sumNumber(@Param("id") Long id, @Param("types") List<Integer> types);

    @Query(value ="select sum(pay_amount) from ieo_odfrecord where status = 1 and user_id=:id",nativeQuery = true)
    BigDecimal sumAmount(@Param("id") Long id);

}
